package com.demo.servlet.demo1209;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/demo1209/demo02.do")
public class Demo02Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter writer = response.getWriter();
        //往网页当中打印请求的所有信息
        writer.println("请求方法：" + request.getMethod() + "<br/>");
        writer.println("getRequestURI()：" + request.getRequestURI() + "<br/>");
        writer.println("getRequestURL()：" + request.getRequestURL() + "<br/>");
        writer.println("getQueryString()：" + request.getQueryString() + "<br/>");
        writer.println("getProtocol()：" + request.getProtocol() + "<br/>");
        writer.println("getContextPath()：" + request.getContextPath() + "<br/>");
        writer.println("getPathInfo()：" + request.getPathInfo() + "<br/>");
        writer.println("getPathTranslated()：" + request.getPathTranslated() + "<br/>");
        writer.println("getServletPath()：" + request.getServletPath() + "<br/>");
        writer.println("getRemoteAddr()：" + request.getRemoteAddr() + "<br/>");
        writer.println("getRemoteHost()：" + request.getRemoteHost() + "<br/>");
        writer.println("getRemotePort()：" + request.getRemotePort() + "<br/>");
        writer.println("getLocalAddr()：" + request.getLocalAddr() + "<br/>");
        writer.println("getLocalName()：" + request.getLocalName() + "<br/>");
        writer.println("getLocalPort()：" + request.getLocalPort() + "<br/>");
        writer.println("getServerName()：" + request.getServerName() + "<br/>");
        writer.println("getServerPort()：" + request.getServerPort() + "<br/>");
        writer.println("getScheme()：" + request.getScheme() + "<br/>");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
